<!DOCTYPE html>












  


<html class="theme-next gemini use-motion" lang="Chinese">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2"/>
<meta name="theme-color" content="#222">












<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />






















<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=6.4.0" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=6.4.0">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=6.4.0">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=6.4.0">


  <link rel="mask-icon" href="/images/logo.svg?v=6.4.0" color="#222">









<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '6.4.0',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: false,
    fastclick: false,
    lazyload: false,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>


  




  <meta name="description" content="在UWP新的设计规范中，汉堡包菜单变成了官方推荐的导航方式，但是并没有提供相应的控件，需要使用SplitView来模拟。 SplitView是分屏视图，把一个视图分割为两部分，Content属性所表示的为主要视图，而Pane属性设置的视图则可以隐藏，可以折叠和展开。 添加SplitView，并加入一些内容    &amp;lt;SplitView.Pane&amp;gt;                    f">
<meta name="keywords" content="UWP,.Net,Windows10">
<meta property="og:type" content="article">
<meta property="og:title" content="UWP学习札记--制作一个简单的汉堡包菜单">
<meta property="og:url" content="http://blog.zhengzi.me/2016/03/05/uwp-e5-bc-80-e5-8f-91-e6-9c-ad-e8-ae-b0-e5-88-b6-e4-bd-9c-e4-b8-80-e4-b8-aa-e7-ae-80-e5-8d-95-e7-9a-84-e6-b1-89-e5-a0-a1-e5-8c-85-e8-8f-9c-e5-8d-95/index.html">
<meta property="og:site_name" content="政子的博客">
<meta property="og:description" content="在UWP新的设计规范中，汉堡包菜单变成了官方推荐的导航方式，但是并没有提供相应的控件，需要使用SplitView来模拟。 SplitView是分屏视图，把一个视图分割为两部分，Content属性所表示的为主要视图，而Pane属性设置的视图则可以隐藏，可以折叠和展开。 添加SplitView，并加入一些内容    &amp;lt;SplitView.Pane&amp;gt;                    f">
<meta property="og:locale" content="Chinese">
<meta property="og:updated_time" content="2018-08-21T09:49:42.773Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="UWP学习札记--制作一个简单的汉堡包菜单">
<meta name="twitter:description" content="在UWP新的设计规范中，汉堡包菜单变成了官方推荐的导航方式，但是并没有提供相应的控件，需要使用SplitView来模拟。 SplitView是分屏视图，把一个视图分割为两部分，Content属性所表示的为主要视图，而Pane属性设置的视图则可以隐藏，可以折叠和展开。 添加SplitView，并加入一些内容    &amp;lt;SplitView.Pane&amp;gt;                    f">






  <link rel="canonical" href="http://blog.zhengzi.me/2016/03/05/uwp-e5-bc-80-e5-8f-91-e6-9c-ad-e8-ae-b0-e5-88-b6-e4-bd-9c-e4-b8-80-e4-b8-aa-e7-ae-80-e5-8d-95-e7-9a-84-e6-b1-89-e5-a0-a1-e5-8c-85-e8-8f-9c-e5-8d-95/"/>



<script type="text/javascript" id="page.configurations">
  CONFIG.page = {
    sidebar: "",
  };
</script>

  <title>UWP学习札记--制作一个简单的汉堡包菜单 | 政子的博客</title>
  









  <noscript>
  <style type="text/css">
    .use-motion .motion-element,
    .use-motion .brand,
    .use-motion .menu-item,
    .sidebar-inner,
    .use-motion .post-block,
    .use-motion .pagination,
    .use-motion .comments,
    .use-motion .post-header,
    .use-motion .post-body,
    .use-motion .collection-title { opacity: initial; }

    .use-motion .logo,
    .use-motion .site-title,
    .use-motion .site-subtitle {
      opacity: initial;
      top: initial;
    }

    .use-motion {
      .logo-line-before i { left: initial; }
      .logo-line-after i { right: initial; }
    }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="Chinese">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">政子的博客</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
    
      
        <p class="site-subtitle">强迫症|学习者|伪文青</p>
      
    
  </div>

  <div class="site-nav-toggle">
    <button aria-label="Toggle navigation bar">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>



<nav class="site-nav">
  
    <ul id="menu" class="menu">
      
        
        
        
          
          <li class="menu-item menu-item-home">
    <a href="/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-home"></i> <br />Home</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-about">
    <a href="/about/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-user"></i> <br />About</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-tags">
    <a href="/tags/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />Tags</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-archives">
    <a href="/archives/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />Archives</a>
  </li>

      
      
    </ul>
  

  

  
</nav>



  



</div>
    </header>

    


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          
            

          
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://blog.zhengzi.me/2016/03/05/uwp-e5-bc-80-e5-8f-91-e6-9c-ad-e8-ae-b0-e5-88-b6-e4-bd-9c-e4-b8-80-e4-b8-aa-e7-ae-80-e5-8d-95-e7-9a-84-e6-b1-89-e5-a0-a1-e5-8c-85-e8-8f-9c-e5-8d-95/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Jason Bian">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="政子的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">UWP学习札记--制作一个简单的汉堡包菜单
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Posted on</span>
              

              
                
              

              <time title="Created: 2016-03-05 11:54:43" itemprop="dateCreated datePublished" datetime="2016-03-05T11:54:43+08:00">2016-03-05</time>
            

            
              

              
                
                <span class="post-meta-divider">|</span>
                

                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                
                  <span class="post-meta-item-text">Edited on</span>
                
                <time title="Modified: 2018-08-21 17:49:42" itemprop="dateModified" datetime="2018-08-21T17:49:42+08:00">2018-08-21</time>
              
            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">In</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/UWP/" itemprop="url" rel="index"><span itemprop="name">UWP</span></a></span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>在UWP新的设计规范中，汉堡包菜单变成了官方推荐的导航方式，但是并没有提供相应的控件，需要使用SplitView来模拟。 SplitView是分屏视图，把一个视图分割为两部分，Content属性所表示的为主要视图，而Pane属性设置的视图则可以隐藏，可以折叠和展开。</p>
<h2 id="添加SplitView，并加入一些内容"><a href="#添加SplitView，并加入一些内容" class="headerlink" title="添加SplitView，并加入一些内容"></a>添加SplitView，并加入一些内容</h2><splitview><br>    &lt;SplitView.Pane&gt;<br>        <stackpanel><br>            <textblock fontsize="20">first</textblock><br>            <textblock fontsize="20">second</textblock><br>            <textblock fontsize="20">third</textblock><br>        </stackpanel><br>    &lt;/SplitView.Pane&gt;<br></splitview>

<h2 id="设置SplitView属性"><a href="#设置SplitView属性" class="headerlink" title="设置SplitView属性"></a>设置SplitView属性</h2><p>设置名字，显示模式，调整打开时的宽度和关闭时的宽度，设置默认不打开</p>
<splitview x:name="mySplit" displaymode="CompactOverlay" compactpanelength="0" openpanelength="150" ispaneopen="False">

<p>具体关于SplitView的见解，可以参照：<a href="http://www.cnblogs.com/tcjiaan/p/4435577.html" target="_blank" rel="noopener">【Win 10应用开发】SplitView控件</a></p>
<h2 id="添加汉堡包按钮极其属性"><a href="#添加汉堡包按钮极其属性" class="headerlink" title="添加汉堡包按钮极其属性"></a>添加汉堡包按钮极其属性</h2><p>需要添加两个按钮，一个位于SplitView之外，用于开启SplitView，另一个在SplitView之内，用于关闭SplitView 需要注意，汉堡包的图案其实是一个矢量字符，在一种Segoe字体中，操作方式很简单，将字体设置为”Segoe MDL2 Assets” 即可，其中汉堡图标为&#xE700;，更多图标可以参考：<a href="http://modernicons.io/segoe-mdl2/cheatsheet/" target="_blank" rel="noopener">http://modernicons.io/segoe-mdl2/cheatsheet/</a></p>
<p>//开启按钮</p>
<p><button click="Button_Click" fontfamily="Segoe MDL2 Assets" content="&#xE700;" verticalalignment="Top" width="50" height="50" background="{ThemeResource ApplicationPageBackgroundThemeBrush}"><br>//关闭按钮</button></p>
<button click="Button_Click" fontfamily="Segoe MDL2 Assets" content="&#xE700;" verticalalignment="Top" width="50" height="50">

<p>两个按钮的Click事件绑定同样的操作Button_Click，作用是打开或关闭SplitView</p>
<p>private void Button_Click(object sender, RoutedEventArgs e)<br>{<br>    mySplit.IsPaneOpen = !mySplit.IsPaneOpen;<br>}</p>
<h2 id="最后做一些外观的微调，改变颜色"><a href="#最后做一些外观的微调，改变颜色" class="headerlink" title="最后做一些外观的微调，改变颜色"></a>最后做一些外观的微调，改变颜色</h2><p>这里附上全部XAML代码</p>
<page x:class="BirthClock.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:BirthClock" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:ignorable="d"><br><br>    <grid background="{ThemeResource ApplicationPageBackgroundThemeBrush}"><br>        <button click="Button_Click" fontfamily="Segoe MDL2 Assets" content="&#xE700;" verticalalignment="Top" width="50" height="50" background="{ThemeResource ApplicationPageBackgroundThemeBrush}"><br>        <splitview x:name="mySplit" displaymode="CompactOverlay" compactpanelength="0" openpanelength="150" ispaneopen="False"><br>            &lt;SplitView.Pane&gt;<br>                <stackpanel background="#FF9F9F9F"><br>                    <button background="#FF9F9F9F" fontfamily="Segoe MDL2 Assets" content="&#xE700;" verticalalignment="Top" width="50" height="50" click="Button_Click"><br>                    <textblock fontsize="20">first</textblock><br>                    <textblock fontsize="20">second</textblock><br>                    <textblock fontsize="20">third</textblock><br>                </button></stackpanel><br>            &lt;/SplitView.Pane&gt;<br>            <textblock horizontalalignment="Center" verticalalignment="Center" fontsize="100">Hello!</textblock><br>        </splitview><br>    </button></grid><br></page>

<p>关于汉堡包菜单更具体的描述可以参考：<a href="http://blog.jerrynixon.com/2015/04/implementing-hamburger-button-with.html" target="_blank" rel="noopener">Implementing an Awesome Hamburger Button with XAML’s new SplitView control in Windows 10</a></p>
</button></splitview>
      
    </div>

    

    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/UWP/" rel="tag"># UWP</a>
          
            <a href="/tags/Net/" rel="tag"># .Net</a>
          
            <a href="/tags/Windows10/" rel="tag"># Windows10</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2016/03/02/e5-8c-97-e9-82-ae-e4-ba-ba-e8-ae-ba-e5-9d-9b-e6-af-8f-e6-97-a5-e5-8d-81-e5-a4-a7-e6-a3-80-e7-b4-a2/" rel="next" title="北邮人论坛每日十大检索">
                <i class="fa fa-chevron-left"></i> 北邮人论坛每日十大检索
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2016/03/06/uwp-e5-ad-a6-e4-b9-a0-e6-9c-ad-e8-ae-b0-e5-9c-a8-e5-ba-94-e7-94-a8-e4-b8-ad-e4-bd-bf-e7-94-a8windows10-e9-a3-8e-e6-a0-bc-e5-9b-be-e6-a0-87/" rel="prev" title="UWP学习札记——在应用中使用Windows10风格图标">
                UWP学习札记——在应用中使用Windows10风格图标 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>


  </div>


          </div>
          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            Table of Contents
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            Overview
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="/images/avatar.jpg"
                alt="Jason Bian" />
            
              <p class="site-author-name" itemprop="name">Jason Bian</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          
            <nav class="site-state motion-element">
              
                <div class="site-state-item site-state-posts">
                
                  <a href="/archives/">
                
                    <span class="site-state-item-count">86</span>
                    <span class="site-state-item-name">posts</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-categories">
                  
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">41</span>
                    <span class="site-state-item-name">categories</span>
                  
                </div>
              

              
                
                
                <div class="site-state-item site-state-tags">
                  
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">109</span>
                    <span class="site-state-item-name">tags</span>
                  
                </div>
              
            </nav>
          

          

          

          
          

          
          

          
            
          
          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#添加SplitView，并加入一些内容"><span class="nav-number">1.</span> <span class="nav-text">添加SplitView，并加入一些内容</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#设置SplitView属性"><span class="nav-number">2.</span> <span class="nav-text">设置SplitView属性</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#添加汉堡包按钮极其属性"><span class="nav-number">3.</span> <span class="nav-text">添加汉堡包按钮极其属性</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#最后做一些外观的微调，改变颜色"><span class="nav-number">4.</span> <span class="nav-text">最后做一些外观的微调，改变颜色</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2018</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Jason Bian</span>

  

  
</div>




  <div class="powered-by">Powered by <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a></div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">Theme – <a class="theme-link" target="_blank" href="https://theme-next.org">NexT.Gemini</a></div>




        








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    
	
    

    
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>


























  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=6.4.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=6.4.0"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=6.4.0"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=6.4.0"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=6.4.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=6.4.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=6.4.0"></script>



  



  










  





  

  

  

  

  
  

  

  

  

  

  

</body>
</html>
